8374804: ConditionalFeature media queries#2161
Conversation
|
👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into |
|
@mstr2 This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
|
/reviewers 2 |
Webrevs
|
|
/csr |
|
@mstr2 has indicated that a compatibility and specification (CSR) request is needed for this pull request. @mstr2 please create a CSR request for issue JDK-8374804 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
|
This looks like a nice addition. I'll review the CSR, but I hope others will review the code. Reviewers: @andy-goryachev-oracle , ??? |
|
yes, it's in my review queue |
andy-goryachev-oracle
left a comment
There was a problem hiding this comment.
Testing looks good. My feedback is mostly about documentation - I know it is very difficult to write docs from a new user perspective, especially since you know how the internals work in great detail.
| </tr> | ||
| <tr> | ||
| <td class="value">-fx-prefers-persistent-scrollbars</td> | ||
| <td class="value nowrap">-fx-prefers-persistent-scrollbars</td> |
There was a problem hiding this comment.
just noticed this: why the -fx prefix is here but not in all the others?
There was a problem hiding this comment.
In CSS, this is called a vendor prefix. It is used for all symbols that have not yet achieved what amounts to universal concensus. JavaFX uses vendor prefixes quite extensively; in fact, almost all styleable properties are vendor-prefixed (though not all: visibility and transition are standard-compliant and don't use a vendor prefix).
Most of the media features we support are standard-compliant, and you'll find that they also work exactly the same in other CSS applications like web browsers. However, -fx-prefers-persistent-scrollbars is not a standard feature; neither is -fx-supports-conditional-feature.
| </tr> | ||
| <tr> | ||
| <td class="value nowrap">-fx-supports-conditional-feature</td> | ||
| <td class="value"> |
There was a problem hiding this comment.
this cell looks way too busy. do you think it might be worth either extracting it into a dedicated table where each feature can be explained/described?
There was a problem hiding this comment.
I've tried arranging the constants in several different ways, including a table-like vertical listing. However, that introduces huge amounts of whitespace that doesn't help readability either. I'm not too excited about adding descriptions to all of the constants; that information is only a click away now that we're linking to the Platform.isSupported(ConditionalFeature) method. I'd like to avoid duplicating normative specification (the CSS reference is a normative specification, not merely an informational document).
There was a problem hiding this comment.
makes sense, especially since you've added the link.
| <span class="nowrap">input-touch</span> | <span class="nowrap">input-multitouch</span> | | ||
| <span class="nowrap">input-pointer</span></td> | ||
| <td>discrete</td> | ||
| <td>Evaluates to <code>true</code> if <code>Platform.isSupported(ConditionalFeature)</code> returns |
There was a problem hiding this comment.
would it be better if this were a link to Platform.isSupported(ConditionalFeature) ?
There was a problem hiding this comment.
Good idea, I've added the link.
| } | ||
| """; | ||
|
|
||
| Stylesheet stylesheet = new CssParserShim().parseUnmerged(stylesheetText, true); |
There was a problem hiding this comment.
in the case of invalid conditional feature like
@media (-fx-supports-conditional-feature: xxx)
{
.button { -fx-background-color: red; }
}
the CssParser writes to stderr - is that expected?
if so, should it be tested?
There was a problem hiding this comment.
In general, I think that CssParser is one of the... let's call it least well-developed parts of JavaFX. Errors from MediaQueryParser are fed back into CssParser, where they are treated like all other errors. So that's not "new" code at work here.
Should the way CssParser reports errors be tested? Maybe, but then again, that time is better spent just discarding it entirely and replacing it with an implementation that's not as bad. In any case, it's out of scope for this PR because the changes here don't touch error reporting at all.
| <td>discrete</td> | ||
| <td>Evaluates to <code>true</code> if <code>Platform.isSupported(ConditionalFeature)</code> returns | ||
| <code>true</code> for the specified conditional feature.<br>This media feature cannot be | ||
| evaluated in a boolean context.</td> |
There was a problem hiding this comment.
Could you please explain in more easily understandable terms that the "boolean context" means? Assume the reader is trying to use it for the first time.
Especially confusing because isSupported is a boolean...
There was a problem hiding this comment.
I've added a link to the paragraph "Evaluating Media Features in a Boolean Context" which appears a bit earlier in the document.
There was a problem hiding this comment.
perfect, thanks!
|
@Maran23 Do you want to to be the second reviewer? |
Yes! Will review and test in the coming days. |
Maran23
left a comment
There was a problem hiding this comment.
Sorry for the delay. Changes look fine and work as expected.
Have 2 very minor suggestions.
| </figure> | ||
| <h5>Evaluating Media Features in a Boolean Context</h5> | ||
| <h5 id="mf-boolean-context">Evaluating Media Features in a Boolean Context</h5> | ||
| <p>If the colon and value is omitted, the media feature is evaluated in a boolean context. |
There was a problem hiding this comment.
Already existing, but this should probably be:
| <p>If the colon and value is omitted, the media feature is evaluated in a boolean context. | |
| <p>If the colon and value are omitted, the media feature is evaluated in a boolean context. |
We can also do that in a follow up, but IMO is close enough so fine for me to do here.
| assertEquals(3, mediaRule.getQueries().size()); | ||
|
|
||
| var expected = FunctionExpression.of("-fx-supports-conditional-feature", "scene3d", _ -> null, true); | ||
| var actual = mediaRule.getQueries().get(0); |
There was a problem hiding this comment.
Very minor: This can be getFirst() (and .get(2) could be getLast() below)
There was a problem hiding this comment.
I usually only do this if I specifically only need the first (or last) element, but not when the code pattern repeats for subsequent elements (0, 1, 2 in this case).
I've reviewed the CSR. It is ready to be Finalized. |
|
/integrate |
This PR adds the
-fx-supports-conditional-featuremedia query, which allows applications to adapt their stylesheets to different platforms with varying conditional feature support. Currently, the built-in themes use hard-coded logic to include or exclude conditional-feature stylesheets. The new media query allows us to potentially remove the hard-coded logic in the future, and gives third-party themes an API to query conditional feature support.Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2161/head:pull/2161$ git checkout pull/2161Update a local copy of the PR:
$ git checkout pull/2161$ git pull https://git.openjdk.org/jfx.git pull/2161/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2161View PR using the GUI difftool:
$ git pr show -t 2161Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2161.diff
Using Webrev
Link to Webrev Comment